home *** CD-ROM | disk | FTP | other *** search
- /*
- PubIt V1.01 LC: 11.August 1994
- Copyright © 1994 by Chris (Confusio) Rickers
-
- Simple tool to open a configurable public screen
- and starts a specified application to run on this
- screen.
-
- Gui created with GadToolsBox
-
- Compile with SAS 6.50+:
-
- SC Pubby.c IGNORE=154+147
- SLINK LIB:c.o LIB:Boopsi.o Pubby.o TO Pubby LIB LIB:sc.lib LIB:scm.lib LIB:amiga2.0.lib LIB:reqtoolsnb.lib
-
- *************************************************************************************************************
-
- NOTE: this source code is not PD, but you can make improvements or adjustments as you like -- as far
- as you obey the following rules:
-
- 1) The new code segment has to be clearly marked as such
- 2) You put a note in the history file.
- 3) You send me the new source for spreadings:
- *** YOU ARE NOT ALLOWED TO DISTRIBUTE THE MODIFIED PROGRAM YOURSELF ***
-
- *************************************************************************************************************
- */
-
- #define DETAIL 0
- #define BLOCK 1
- #define TEXTP 2
- #define SHINE 3
- #define SHADOW 4
- #define FILL 5
- #define FILLTEXT 6
- #define BACKGR 7
- #define HITEXT 8
- #define BDETAIL 9
- #define BBLOCK 10
- #define BTRIM 11
-
- /// Include List
- #include <exec/types.h>
- #include <exec/libraries.h>
- #include <dos/dos.h>
- #include <dos/dostags.h>
- #include <intuition/intuition.h>
- #include <intuition/IntuitionBase.h>
- #include <intuition/screens.h>
- #include <intuition/classes.h>
- #include <intuition/classusr.h>
- #include <intuition/imageclass.h>
- #include <intuition/gadgetclass.h>
- #include <graphics/gfx.h>
- #include <graphics/GfxBase.h>
- #include <graphics/modeid.h>
- #include <graphics/gfxmacros.h>
- #include <libraries/diskfont.h>
- #include <libraries/reqtools.h>
- #include <libraries/gadtools.h>
- #include <workbench/workbench.h>
- #include <workbench/startup.h>
-
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/diskfont_protos.h>
- #include <clib/reqtools_protos.h>
- #include <clib/alib_protos.h>
- #include <clib/utility_protos.h>
-
- #include <pragmas/intuition_pragmas.h>
- #include <pragmas/graphics_pragmas.h>
- #include <pragmas/utility_pragmas.h>
-
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/diskfont.h>
- #include <proto/icon.h>
- #include <proto/gadtools.h>
-
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
-
- #include "PubIt.h" // GadToolsBox Header File
- ///
-
- /// Structures and Variables
-
- // Structures
- extern struct ExecBase *SysBase;
- extern struct DosLibrary *DOSBase;
- struct WBStartup *IconArgs;
- struct Library *IntuitionBase;
- struct GfxBase *GfxBase;
- struct Library *DiskfontBase;
- struct Library *IconBase;
- struct Library *GadToolsBase;
- struct Library *ReqToolsBase;
- struct Window *syswin = NULL;
- struct Process *PubbyProc = NULL;
-
- // GadToolsBox Structures 'n vars...
-
- APTR VisualInfo;
- struct Screen *Scr = NULL;
- UBYTE *PubScreenName = NULL;
- struct Window *PubbyMainWnd = NULL,
- *DriPenAdjustWnd = NULL,
- *ApplicationDataWnd = NULL;
- struct Gadget *DriPenAdjustGList = NULL,
- *ApplicationDataGList = NULL;
- struct Menu *PubbyMainMenus = NULL;
- struct IntuiMessage PubbyMainMsg,
- DriPenAdjustMsg,
- ApplicationDataMsg;
- struct Gadget *DriPenAdjustGadgets[3],
- *ApplicationDataGadgets[5];
- struct NewGadget DriPenAdjustNGad[],
- ApplicationDataNGad[];
- struct IClass *getClass = NULL;
- struct _Object *getImage = NULL;
- struct TextAttr *Font, Attr;
-
- struct TextFont *PubbyMainFont = NULL;
- struct TextFont *DriPenAdjustFont = NULL;
- struct TextFont *ApplicationDataFont = NULL;
- struct TextFont *ScrFont = NULL;
- struct TextAttr ScrAttr = {
- "helvetica.font ",
- 13,
- FS_NORMAL,
- FPB_ROMFONT|FPB_DISKFONT,
- };
-
- // GUI Data...
-
- UBYTE *driadjust_pens1Labels[] = {
- (UBYTE *)"Detail", (UBYTE *)"Block", (UBYTE *)"Text", (UBYTE *)"Shine", (UBYTE *)"Shadow", (UBYTE *)"Fill",
- (UBYTE *)"FillText", (UBYTE *)"Background", (UBYTE *)"HighlightText", (UBYTE *)"BarDetail", (UBYTE *)"BarBlock",
- (UBYTE *)"BarTrim", NULL };
-
- struct NewMenu PubbyMainNewMenu[] = {
- NM_TITLE, (STRPTR)"PubIt-Project", NULL, 0, NULL, NULL,
- NM_ITEM, (STRPTR)"Screen Mode...", (STRPTR)"m", 0, 0L, (APTR)PubbyMainsmode,
- NM_ITEM, (STRPTR)"Color-Palette...", (STRPTR)"p", 0, 0L, (APTR)PubbyMaincpalette,
- NM_ITEM, (STRPTR)"Define DriPens...", (STRPTR)"d", 0, 0L, (APTR)PubbyMaindripens,
- NM_ITEM, (STRPTR)"Font...", (STRPTR)"f", 0, 0L, (APTR)PubbyMainfont,
- NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
- NM_ITEM, (STRPTR)"Set Application...",(STRPTR)"a", 0, 0L, (APTR)PubbyMainappdata,
- NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
- NM_ITEM, (STRPTR)"About", NULL, 0, 0L, (APTR)PubbyMainabout,
- NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
- NM_ITEM, (STRPTR)"Save...", (STRPTR)"s", 0, 0L, (APTR)PubbyMainsave,
- NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
- NM_ITEM, (STRPTR)"Quit.", (STRPTR)"q", 0, 0L, (APTR)PubbyMainquit,
- NM_END, NULL, NULL, 0, 0L, NULL };
-
- UWORD DriPenAdjustGTypes[] = { PALETTE_KIND, CYCLE_KIND, BUTTON_KIND };
-
- UWORD ApplicationDataGTypes[] = { STRING_KIND, INTEGER_KIND, INTEGER_KIND, BUTTON_KIND, GENERIC_KIND };
-
- struct NewGadget DriPenAdjustNGad[] = {
- 48, 30, 130, 26, (UBYTE *)"_Color", NULL, GD_driadjust_palette, PLACETEXT_LEFT, NULL, (APTR)driadjust_paletteClicked,
- 48, 12, 128, 16, (UBYTE *)"_Pens", NULL, GD_driadjust_pens, PLACETEXT_LEFT, NULL, (APTR)driadjust_pensClicked,
- 147, 64, 56, 14, (UBYTE *)"_OK", NULL, GD_driadjust_OK, PLACETEXT_IN, NULL, (APTR)driadjust_OKClicked
- };
-
- struct NewGadget ApplicationDataNGad[] = {
- 76, 12, 97, 15, (UBYTE *)"_Path/File:", NULL, GD_app_path, PLACETEXT_LEFT, NULL, (APTR)app_pathClicked,
- 76, 29, 118, 15, (UBYTE *)"_Stack:", NULL, GD_Gadget12, PLACETEXT_LEFT, NULL, (APTR)Gadget12Clicked,
- 76, 46, 118, 15, (UBYTE *)"_Priority:", NULL, GD_apppri, PLACETEXT_LEFT, NULL, (APTR)apppriClicked,
- 138, 70, 56, 14, (UBYTE *)"_OK", NULL, GD_appok, PLACETEXT_IN, NULL, (APTR)appokClicked,
- 176, 13, 20, 14, NULL, NULL, GD_appgetfile, 0, NULL, (APTR)appgetfileClicked
- };
-
- ULONG DriPenAdjustGTags[] = {
- (GTPA_Depth), 8, (GTPA_Color), 1, (GTPA_ColorOffset), 0, (GT_Underscore), '_', (TAG_DONE),
- (GTCY_Labels), (ULONG)&driadjust_pens1Labels[ 0 ], (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE)
- };
-
- ULONG ApplicationDataGTags[] = {
- (GTST_String), (ULONG)"My Application!", (GTST_MaxChars), 180, (GT_Underscore), '_', (TAG_DONE),
- (GA_TabCycle), FALSE, (GTIN_Number), 4096, (GTIN_MaxChars), 10, (GT_Underscore), '_', (TAG_DONE),
- (GA_TabCycle), FALSE, (GTIN_Number), 0, (GTIN_MaxChars), 10, (GT_Underscore), '_', (TAG_DONE),
- (GT_Underscore), '_', (TAG_DONE),
- (TAG_DONE)
- };
-
- // Variables
-
- UBYTE PubScrName[20] = "PUBSCR.1";
- UBYTE PubTitle[100] = "PubIt, Copyright © 1994 by Chris (Confusio) Rickers";
- UBYTE AppName[200];
- LONG AppPri=0;
- ULONG AppStack=4096, Width=640, Height=200, Depth=2, ID = DEFAULT_MONITOR_ID|LORES_KEY;
- UWORD DriPens[13] = { 0,1,1,2,1,3,2,0,2,1,2,1,};
- UBYTE TTARRAY[12][20] = { { "DETAIL"}, { "BLOCK"}, {"TEXT"}, { "SHINE"},
- { "SHADOW"}, { "FILL"} , { "FILLTEXT" },
- { "BACKGROUND"} ,{ "HIGHLIGHTTEXT"} ,
- { "BARDETAIL" }, { "BARFILL"} , { "BARTRIM" }
- };
- UBYTE FONTNAME[40] = "topaz.font";
- UWORD FONTSIZE = 8;
- int SelectedDriPen = 0;
- BOOL INTERLEAVED = FALSE, _SHANGHAI = FALSE;
- UWORD OldPubModes = NULL;
- UBYTE App_HomeDir[200];
- UBYTE App_CurrDir[200];
- UBYTE App_Args[200];
- BOOL FQUIT=FALSE;
- BOOL FWQUIT=FALSE;
- BOOL SHOWNAME=TRUE;
- static UBYTE formstr[200];
-
- // GadToolsBox
-
- UWORD PubbyMainLeft = 0,
- PubbyMainTop = 10,
- PubbyMainWidth = 100,
- PubbyMainHeight = 100;
- UWORD DriPenAdjustLeft = 23,
- DriPenAdjustTop = 63,
- DriPenAdjustWidth = 213,
- DriPenAdjustHeight = 82;
- UWORD ApplicationDataLeft = 70,
- ApplicationDataTop = 45,
- ApplicationDataWidth = 202,
- ApplicationDataHeight = 90;
-
- UBYTE *PubbyMainWdt = NULL; // will become a borderless backdrop window, so no title
- UBYTE *DriPenAdjustWdt = (UBYTE*)"Define DriPens...";
- UBYTE *ApplicationDataWdt = (UBYTE*)"Application Data..:";
-
- UWORD FontX, FontY;
- UWORD OffX, OffY;
-
- // static, Arrghhh!!!
-
- UBYTE mycolors[768] =
- {
- 8,8,8,
- 0,0,0,
- 15,15,15,
- 6,9,13,
- 14,0,2,
- 2,15,2,
- 14,8,0,
- 0,0,0,
- }; // ...
-
- ///
-
- /// Prototypes
-
- // Private Prototypes
-
- void openall( void ); // Opens screen and makes it public, after having read the prefs for that screen.
- void closeall( void );
- static BOOL ReplaceTool(UBYTE **ttarr, UBYTE *ts, UBYTE *rps);
- void RenderLine(struct RastPort *, UWORD, UWORD, UWORD, UWORD );
- int updatescreen( void );
- void setcolors( void );
- void getcolors( void );
- int RunApp( void );
-
- // GadToolsBox Prototypes
-
- extern Class *initGet( void );
- static UWORD ComputeX( UWORD );
- static UWORD ComputeY( UWORD );
- static void ComputeFont( UWORD, UWORD );
- int SetupScreen( void );
- int CloseDownScreen( void );
- int HandlePubbyIDCMP( void );
- int OpenPubbyMainWindow( void );
- void ClosePubbyMainWindow( void );
- int PubbyMainCloseWindow( void );
- int DriPenAdjustCloseWindow( void );
- int ApplicationDataCloseWindow( void );
- ///
-
- UBYTE vstr[] = "$VER: PubIt V1.01, LC: 29.08.1994";
-
- /// setcolors( )
- void setcolors(void)
- {
- short i;
-
- for(i=0;i< pow(2.0,(double)Depth) ;i++)
- SetRGB4(&Scr->ViewPort,(long)i,(long)mycolors[i*3],
- (long)mycolors[i*3+1],(long)mycolors[i*3+2]);
- }
- ///
-
- /// getcolors( )
- void getcolors(void)
- {
- long color;
- short i;
-
- for(i=0;i<pow(2.0,(double)Depth);i++)
- {
- color=GetRGB4(Scr->ViewPort.ColorMap,(long)i);
- mycolors[i*3]=( color>>8 ) & 0xf;
- mycolors[i*3+1]=( color>>4 ) & 0xf;
- mycolors[i*3+2]= color & 0xf;
- }
- }
- ///
-
- /// RenderLine( )
- void RenderLine(struct RastPort *rp, UWORD x1, UWORD y1, UWORD x2, UWORD y2)
- {
- SetAPen(rp,DriPens[3]); // shine pen
- if(x1!=x2 && y2!=y2)
- return;
- if(x1==x2){
- SetAPen(rp,DriPens[4]); // shadow pen
- Move(rp,x1,y1);
- Draw(rp,x1,y2);
- SetAPen(rp,DriPens[3]); // shine pen
- Move(rp,x1+1,y2);
- Draw(rp,x1+1,y1+1);
- return;
- }
- else{
- Move(rp,x1,y1);
- Draw(rp,x2,y2);
- Draw(rp,x2,y2-1);
- SetAPen(rp,DriPens[4]); // shadow pen
- Move(rp,x2-1,y2-1);
- Draw(rp,x1,y1-1);
- Draw(rp,x1,y1);
- return;
- }
- }
- ///
-
- /// RunApp( )
- int RunApp( void )
- {
- long error = NULL;
- UBYTE comString[500];
- BPTR nilptr = NULL;
-
- if(strlen(AppName) <= 0)
- return((int) 0 );
-
- nilptr = Open("NIL:",MODE_NEWFILE); // avoid error-output windows on wb
-
- sprintf(comString, "%s %s\n",AppName,App_Args);
- error=SystemTags(comString,
- NP_StackSize, AppStack,
- NP_Name, "PubIt-Application",
- NP_Priority, AppPri,
- SYS_Output, nilptr,
- TAG_END);
-
- Close(nilptr);
- nilptr = NULL;
-
- if(error!=0){
- if(error==-1)
- rtEZRequestTags("PubIt-Error:\n"
- "Unable to launch application!","Shit!",
- 0l,0l,RT_PubScrName,PubScrName,TAG_END);
- else
- rtEZRequestTags("PubIt-Error:\n"
- "Application returned an error!","OK!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- }
-
- /*
- app_process = CreateNewProcTags(NP_Seglist, seglist,
- // NP_CurrentDir, App_CurrDir,
- // NP_HomeDir, App_HomeDir,
- // NP_Arguments, App_Args,
- TAG_END);
- }
- else
- app_process = CreateNewProcTags(NP_Seglist, seglist,
- // NP_CurrentDir, App_CurrDir,
- NP_StackSize, AppStack,
- // NP_Name, "PubIt-Application",
- // NP_Priority, AppPri,
- // NP_HomeDir, App_HomeDir,
- TAG_END);
-
-
- if( NOT app_process ) {
- rtEZRequestTags("PubIt-Error:\nError creating new application process!","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- if(NOT UnLoadSeg( seglist ))
- rtEZRequestTags("PubIt-Error:\n"
- "Unable to Unload Seglist of your \n"
- "application --> Memory Trash","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- return((int)0); // no application started
- }
- rtEZRequestTags("Application Runs!","OK!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- */
-
- return((int)1); // application should run asynch, now.
- }
- ///
-
- /// ComputeX( )
- static UWORD ComputeX( UWORD value )
- { return( (UWORD) ((( FontX * value ) + 3 ) / 6 ));
- }
- ///
-
- /// ComputeY( )
- static UWORD ComputeY( UWORD value )
- { return((UWORD) ((( FontY * value ) +5 ) / 11 ));
- }
- ///
-
- /// ComputeFont( )
- static void ComputeFont( UWORD width, UWORD height )
- {
-
- if(strlen(FONTNAME)<=0)
- goto UseTopaz;
-
- Font = &ScrAttr;
- Font->ta_Name = FONTNAME;
- Font->ta_YSize = FontY = FONTSIZE;
- FontX = ScrFont->tf_XSize;
-
- OffX = Scr->WBorLeft;
- OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
-
- if ( width && height ) {
- if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
- goto UseTopaz;
- if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
- goto UseTopaz;
- }
- return;
-
- UseTopaz:
- Font->ta_Name = (STRPTR)"topaz.font";
- FontX = FontY = Font->ta_YSize = 8;
- }
- ///
-
- /// SetupScreen( )
- int SetupScreen( void )
- {
- ScrAttr.ta_Name = (STRPTR)FONTNAME;
- ScrAttr.ta_YSize = (UWORD)FONTSIZE;
-
- if(SHOWTITLE)
- sprintf(formstr, "%s <%s>",PubTitle,PubScrName);
- else
- strcpy(formstr, PubTitle);
-
- if(!(ScrFont = (struct TextFont *)OpenDiskFont( &ScrAttr)))
- {
- rtEZRequestTags("PubIt-Error:\n\nUnable to open specified\n"
- "font \"%s\"!","OK!",0l,ScrAttr.ta_Name,RT_PubScrName,PubScrName,TAG_END);
- return((int)0);
- }
-
- if( ! ( Scr = OpenScreenTags ( NULL, SA_Left , 0 ,
- SA_Top, 0,
- SA_Width, Width,
- SA_Height, Height,
- SA_Depth, Depth,
- SA_Type, PUBLICSCREEN,
- SA_PubName, PubScrName,
- SA_DisplayID, ID,
- SA_AutoScroll, TRUE,
- SA_Overscan, OSCAN_TEXT,
- SA_Interleaved, INTERLEAVED,
- SA_Pens, &DriPens[0],
- SA_Font, &ScrAttr,
- SA_Title, formstr,
- TAG_DONE ))){
- return( (int) 0 );
- }
-
- ComputeFont( 0, 0 );
-
- if( ! ( VisualInfo = GetVisualInfo ( Scr, TAG_DONE ))){
- return( (int) 0 );
- }
-
- if( ! ( getClass = initGet() )){
- rtEZRequestTags("No getClass","OK!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- return( (int) 0 );
- }
-
- if( ! ( getImage = NewObject( getClass, NULL, GT_VisualInfo, VisualInfo, TAG_DONE ))){
- #ifdef DEBUG
- rtEZRequestTags("No getImage!","OK!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- #endif // DEBUG
- return( (int) 0 );
- }
-
- PubScreenStatus(Scr,0);
- setcolors( ) ;
-
- if(_SHANGHAI){
- SetDefaultPubScreen(PubScrName);
- OldPubModes = SetPubScreenModes( SHANGHAI );
- }
- return( (int) 1);
- }
- ///
-
- /// CloseDownScreen( )
- int CloseDownScreen( void )
- {
- while( Scr->FirstWindow )
- rtEZRequestTags("Please close all windows first,\nthen click on \"Retry!\"","Retry!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
-
- if(_SHANGHAI){ // this is not modified during runtime
- SetPubScreenModes( OldPubModes );
- SetDefaultPubScreen( NULL );
- }
-
- if( getImage )
- DisposeObject( getImage );
- if( getClass )
- FreeClass( getClass );
- if( VisualInfo )
- FreeVisualInfo( VisualInfo );
- if( Scr )
- CloseScreen( Scr );
-
- Scr = NULL;
- VisualInfo = NULL;
- getClass = NULL;
- getImage = NULL;
-
- if(ScrFont){
- CloseFont(ScrFont);
- ScrFont = NULL;
- }
-
- return( (int) 1 );
- }
- ///
-
- /// HandlePubbyMainIDCMP( ) TO BE OPTIMIZED
- int HandlePubbyMainIDCMP( void )
- {
- struct IntuiMessage *m;
- struct MenuItem *n;
- int (*func)();
- BOOL running = TRUE;
-
- for(;;){
- if(( m = GT_GetIMsg( PubbyMainWnd->UserPort ))==NULL)
- WaitPort(PubbyMainWnd->UserPort);
- else{
- CopyMem(( char * )m, ( char * )&PubbyMainMsg, (long)sizeof( struct IntuiMessage ));
-
- GT_ReplyIMsg( m );
- switch ( PubbyMainMsg.Class ) {
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh( PubbyMainWnd );
- GT_EndRefresh( PubbyMainWnd, TRUE );
- break;
- case IDCMP_CLOSEWINDOW:
- return((int)(running = PubbyMainCloseWindow()));
- break;
- case IDCMP_MENUPICK:
- while( PubbyMainMsg.Code != MENUNULL ) {
- n = ItemAddress( PubbyMainMenus, PubbyMainMsg.Code );
- func = (void *)(GTMENUITEM_USERDATA( n ));
- return((int)func());
- }
- break;
- } // switch
- } // if
- } // for(;;)
- }
- ///
-
- /// OpenPubbyMainWindow( )
- int OpenPubbyMainWindow( void )
- {
- UWORD wleft = 0,
- wtop = Scr->BarHeight + 2;
-
- PubbyMainWidth = 100;
- PubbyMainHeight = 100;
-
- if ( ! ( PubbyMainFont = OpenDiskFont( Font )))
- return( (int) 0 );
- if ( ! ( PubbyMainMenus = CreateMenus( PubbyMainNewMenu, GTMN_FrontPen, 1L, TAG_DONE )))
- return( (int) 0 );
-
- LayoutMenus( PubbyMainMenus, VisualInfo, TAG_DONE );
-
- if ( ! ( PubbyMainWnd = OpenWindowTags( NULL,
- WA_Left, wleft,
- WA_Top, wtop,
- WA_Width, 100,
- WA_Height, 100,
- WA_IDCMP, IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
- WA_Flags, WFLG_NEWLOOKMENUS|WFLG_SMART_REFRESH|WFLG_ACTIVATE|WFLG_BACKDROP|WFLG_BORDERLESS,
- WA_Title, PubbyMainWdt,
- WA_PubScreen, Scr,
- WA_PubScreenName, PubScrName,
- WA_AutoAdjust, TRUE,
- WA_MinWidth, 10,
- WA_MinHeight, 10,
- WA_MaxWidth, PubbyMainWidth,
- WA_MaxHeight, PubbyMainHeight,
- TAG_DONE )))
- return( (int) 0 );
-
- PubbyProc=(struct Process *)FindTask(NULL);
- syswin=PubbyProc->pr_WindowPtr;
- PubbyProc->pr_WindowPtr = (APTR) PubbyMainWnd;
-
- SetMenuStrip( PubbyMainWnd, PubbyMainMenus );
- GT_RefreshWindow( PubbyMainWnd, NULL );
- return( (int) 1 );
- }
- ///
-
- /// ClosePubbyMainWindow( )
- void ClosePubbyMainWindow( void )
- {
- PubbyProc->pr_WindowPtr = syswin;
-
- if ( PubbyMainMenus )
- {
- ClearMenuStrip( PubbyMainWnd );
- FreeMenus( PubbyMainMenus );
- PubbyMainMenus = NULL;
- }
-
- if ( PubbyMainWnd )
- {
- CloseWindow( PubbyMainWnd );
- PubbyMainWnd = NULL;
- }
-
- if ( PubbyMainFont )
- {
- CloseFont( PubbyMainFont );
- PubbyMainFont = NULL;
- }
- }
- ///
-
- /// DriPenAdjustRender( )
- void DriPenAdjustRender( void )
- {
- ComputeFont( DriPenAdjustWidth, DriPenAdjustHeight );
- RenderLine(DriPenAdjustWnd->RPort, OffX + ComputeX( 0 ), OffY + ComputeY( 60 ), OffX+ComputeX( 213 ), OffY+ComputeY( 60 ) );
- DrawBevelBox( DriPenAdjustWnd->RPort, OffX + ComputeX( 178 ),OffY + ComputeY( 30 ),ComputeX( 27 ),ComputeY( 25 ),GT_VisualInfo, VisualInfo, GTBB_Recessed, TRUE, TAG_DONE );
- }
- ///
-
- /// HandleDriPenAdjustIDCMP( ) TO BE OPTIMIZED
- int HandleDriPenAdjustIDCMP( void )
- {
- struct IntuiMessage *m;
- int (*func)();
- BOOL running = TRUE;
-
- while( m = GT_GetIMsg( DriPenAdjustWnd->UserPort )) {
- CopyMem(( char * )m, ( char * )&DriPenAdjustMsg, (long)sizeof( struct IntuiMessage ));
- GT_ReplyIMsg( m );
- switch ( DriPenAdjustMsg.Class ) {
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh( DriPenAdjustWnd );
- DriPenAdjustRender();
- GT_EndRefresh( DriPenAdjustWnd, TRUE );
- break;
- case IDCMP_CLOSEWINDOW:
- running = DriPenAdjustCloseWindow();
- break;
- case IDCMP_GADGETUP:
- func = ( void * )(( struct Gadget * )DriPenAdjustMsg.IAddress )->UserData;
- running = func();
- break;
- }
- }
- return( (int) running );
- }
- ///
-
- /// OpenDriPenAdjustWindow( )
- int OpenDriPenAdjustWindow( void )
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc, tc;
- UWORD wleft = DriPenAdjustLeft,
- wtop = DriPenAdjustTop,
- ww, wh;
-
- ComputeFont( DriPenAdjustWidth, DriPenAdjustHeight );
- ww = ComputeX( DriPenAdjustWidth );
- wh = ComputeY( DriPenAdjustHeight );
-
- if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
- if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
-
- if ( ! ( DriPenAdjustFont = OpenDiskFont( Font )))
- return( (int) 0 );
- if ( ! ( g = CreateContext( &DriPenAdjustGList )))
- return( (int) 0 );
-
- DriPenAdjustGTags[1] = Depth; // this is `set only!'
-
- for( lc = 0, tc = 0; lc < DriPenAdjust_CNT; lc++ ) {
- CopyMem((char * )&DriPenAdjustNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = Font;
- ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
- ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
- ng.ng_Width = ComputeX( ng.ng_Width );
- ng.ng_Height = ComputeY( ng.ng_Height);
- DriPenAdjustGadgets[ lc ] = g = CreateGadgetA((ULONG)DriPenAdjustGTypes[ lc ], g, &ng, ( struct TagItem * )&DriPenAdjustGTags[ tc ] );
-
- while( DriPenAdjustGTags[ tc ] )
- tc += 2;
-
- tc++;
- if ( NOT g )
- return( (int) 0 );
- } // for()
-
- if ( ! ( DriPenAdjustWnd = OpenWindowTags( NULL,
- WA_Left, wleft,
- WA_Top, wtop,
- WA_Width, ww + OffX + Scr->WBorRight,
- WA_Height, wh + OffY + Scr->WBorBottom,
- WA_IDCMP, PALETTEIDCMP|CYCLEIDCMP|BUTTONIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Gadgets, DriPenAdjustGList,
- WA_Title, DriPenAdjustWdt,
- WA_PubScreen, Scr,
- WA_AutoAdjust, TRUE,
- TAG_DONE )))
- return( (int) 0 );
-
- GT_RefreshWindow( DriPenAdjustWnd, NULL );
- DriPenAdjustRender();
- return( (int) 1 );
- }
- ///
-
- /// CloseDriPenAdjustWindow( )
- void CloseDriPenAdjustWindow( void )
- {
- if ( DriPenAdjustWnd )
- CloseWindow( DriPenAdjustWnd );
- if ( DriPenAdjustGList )
- FreeGadgets( DriPenAdjustGList );
- if ( DriPenAdjustFont )
- CloseFont( DriPenAdjustFont );
-
- DriPenAdjustWnd = NULL;
- DriPenAdjustGList = NULL;
- DriPenAdjustFont = NULL;
-
- updatescreen( ); // close screen, and reopen with new dripens
- }
- ///
-
- /// ApplicationDataRender( )
- void ApplicationDataRender( void )
- {
- ComputeFont( ApplicationDataWidth, ApplicationDataHeight );
- RenderLine( ApplicationDataWnd->RPort, OffX + ComputeX( 0 ), OffY + ComputeY( 64 ), OffX+ComputeX( 202 ), OffY+ComputeY( 64 ) );
- }
- ///
-
- /// HandleApplicationDataIDCMP( ) TO BE OPTIMIZED
- int HandleApplicationDataIDCMP( void )
- {
- struct IntuiMessage *m;
- int (*func)();
- BOOL running = TRUE;
-
- while( m = GT_GetIMsg( ApplicationDataWnd->UserPort )) {
- CopyMem(( char * )m, ( char * )&ApplicationDataMsg, (long)sizeof( struct IntuiMessage ));
- GT_ReplyIMsg( m );
- switch ( ApplicationDataMsg.Class ) {
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh( ApplicationDataWnd );
- ApplicationDataRender();
- GT_EndRefresh( ApplicationDataWnd, TRUE );
- break;
- case IDCMP_CLOSEWINDOW:
- running = ApplicationDataCloseWindow();
- break;
- case IDCMP_GADGETUP:
- func = ( void * )(( struct Gadget * )ApplicationDataMsg.IAddress )->UserData;
- running = func();
- break;
- }
- }
- return( (int) running );
- }
- ///
-
- /// OpenApplicationDataWindow( )
- int OpenApplicationDataWindow( void )
- {
- struct NewGadget ng;
- struct Gadget *g;
- UWORD lc, tc;
- UWORD wleft = ApplicationDataLeft, wtop = ApplicationDataTop, ww, wh;
-
- ComputeFont( ApplicationDataWidth, ApplicationDataHeight );
- ww = ComputeX( ApplicationDataWidth );
- wh = ComputeY( ApplicationDataHeight );
-
- if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
- if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
-
- if ( ! ( ApplicationDataFont = OpenDiskFont( Font )))
- return( (int) 0 );
- if ( ! ( g = CreateContext( &ApplicationDataGList )))
- return( (int) 0 );
-
- for( lc = 0, tc = 0; lc < ApplicationData_CNT; lc++ ) {
- CopyMem((char * )&ApplicationDataNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
- ng.ng_VisualInfo = VisualInfo;
- ng.ng_TextAttr = Font;
- ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
- ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
- if ( ApplicationDataGTypes[ lc ] != GENERIC_KIND ) {
- ng.ng_Width = ComputeX( ng.ng_Width );
- ng.ng_Height = ComputeY( ng.ng_Height);
- }
- ApplicationDataGadgets[ lc ] = g = CreateGadgetA((ULONG)ApplicationDataGTypes[ lc ], g, &ng, ( struct TagItem * )&ApplicationDataGTags[ tc ] );
- if ( ApplicationDataGTypes[ lc ] == GENERIC_KIND ) {
- g->Flags |= GFLG_GADGIMAGE | GFLG_GADGHIMAGE;
- g->Activation |= GACT_RELVERIFY;
- g->GadgetRender = (APTR)getImage;
- g->SelectRender = (APTR)getImage;
- }
- while( ApplicationDataGTags[ tc ] )
- tc += 2;
- tc++;
- if ( NOT g )
- return( (int) 0 );
- } // for()
-
- ApplicationDataGadgets[GD_appgetfile]->TopEdge = ApplicationDataGadgets[0]->TopEdge + ApplicationDataGadgets[0]->Height - 14;
-
- if ( ! ( ApplicationDataWnd = OpenWindowTags( NULL,
- WA_Left, wleft,
- WA_Top, wtop,
- WA_Width, ww + OffX + Scr->WBorRight,
- WA_Height, wh + OffY + Scr->WBorBottom,
- WA_IDCMP, STRINGIDCMP|INTEGERIDCMP|BUTTONIDCMP|IDCMP_GADGETUP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
- WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
- WA_Gadgets, ApplicationDataGList,
- WA_Title, ApplicationDataWdt,
- WA_PubScreen, Scr,
- WA_AutoAdjust, TRUE,
- TAG_DONE )))
- return( (int) 0 );
-
- GT_SetGadgetAttrs(ApplicationDataGadgets[GD_app_path],ApplicationDataWnd,NULL,GTST_String,AppName,TAG_END);
- GT_SetGadgetAttrs(ApplicationDataGadgets[GD_apppri], ApplicationDataWnd, NULL,
- GTIN_Number, AppPri, TAG_END);
- GT_SetGadgetAttrs(ApplicationDataGadgets[GD_Gadget12],ApplicationDataWnd,NULL,
- GTIN_Number, AppStack,TAG_END);
-
- GT_RefreshWindow( ApplicationDataWnd, NULL );
- ApplicationDataRender();
- return( (int) 1 );
- }
- ///
-
- /// CloseApplicationDataWindow( )
- void CloseApplicationDataWindow( void )
- {
- if ( ApplicationDataWnd )
- CloseWindow( ApplicationDataWnd );
- if ( ApplicationDataGList )
- FreeGadgets( ApplicationDataGList );
- if ( ApplicationDataFont )
- CloseFont( ApplicationDataFont );
-
- ApplicationDataWnd = NULL;
- ApplicationDataGList = NULL;
- ApplicationDataFont = NULL;
- }
- ///
-
- /// ParseIconArgs( )
- // reads tooltypes into global static vars, supported tooltypes are:
- // APPNAME the name of the application to start
- // APPPRI the taskpriority of the application to start
- // APPSTACK the stacksize of the app.
- // APPARGS
- // PUBNAME Name of the public screen, which pubby will open.
- // PUBTITLE titlebar text of public screen
- // SHOWNAME yes / no display pubscreen name in title bar
- // DEPTH Number of colors the screen will have
- // WIDTH Width of screen
- // HEIGHT height of screen
- // DISPLAYID displayid of screenmode to open in
- // FONTNAME name of screen font
- // FONTSIZE size of the font
- // POPSTART YES / NO, popup the screenmode requester before opening the screen *
- // INTERLEAVED YES / NO. screen uses interleaved bitmaps *
- // SHANGHAI YES / NO. open wb windows on screen or not *
- // FQUIT YES / NO. quit immediately afrer application has finished *
- // FWQUIT YES / NO. quit immediately, after all windows are closed *
- //
- // * are only read, not written by Pubby
-
- WORD ParseIconArgs( struct WBStartup *wbs )
- {
- struct DiskObject *dobj;
- UBYTE **tarray;
- UBYTE *s;
- register int i = 0;
- struct rtScreenModeRequester *scrreq = NULL;
-
- BPTR fptr = NULL; // DOS stuff
- UBYTE palname[250]; // pathname of app-specific palette
-
- if(!wbs)
- return((WORD)0);
-
- CurrentDir(wbs->sm_ArgList->wa_Lock);
-
- if(dobj = GetDiskObject(wbs->sm_ArgList->wa_Name))
- {
- tarray = (char **) dobj->do_ToolTypes;
-
- if( s = FindToolType( tarray, "PUBNAME" ))
- strncpy( PubScrName, s, 20 );
- if( s = FindToolType( tarray, "APPNAME" ))
- strncpy( AppName, s, 200 );
- if( s = FindToolType( tarray, "APPPRI" ))
- AppPri = atol(s);
- else
- AppPri = 0;
- if( s = FindToolType( tarray, "APPSTACK" ))
- AppStack = atol( s );
- else
- AppStack = 4096;
-
- if( s = FindToolType( tarray, "FQUIT" ))
- if(strcmp(s,"YES")==0)
- FQUIT=TRUE;
- else
- FQUIT=FALSE;
-
- if( s = FindToolType( tarray, "FWQUIT" ))
- if(strcmp(s,"YES")==0){
- FWQUIT=TRUE;
- FQUIT =FALSE;
- }
- else
- FWQUIT=FALSE;
-
- if( s = FindToolType( tarray, "APPARGS" ))
- strncpy(App_Args, s, 200);
-
- if( s = FindToolType( tarray, "PUBNAME" ))
- strncpy(PubScrName, s, 20);
-
- if( s = FindToolType( tarray, "PUBTITLE" ))
- strncpy(PubTitle, s, 100);
-
- if( s = FindToolType( tarray, "DEPTH" ))
- Depth = atol( s );
- else
- Depth = 2; // 4 colors default
- if( s = FindToolType( tarray, "WIDTH" ))
- Width = atol( s );
- else
- Width = 640;
- if( s = FindToolType( tarray, "HEIGHT" ))
- Height = atol( s );
- else
- Height = 256;
- if( s = FindToolType( tarray, "DISPLAYID" )){
- if( atol ( s ) != 0 ){
- ID = atol( s );
- }
- }
- else
- ID = DEFAULT_MONITOR_ID|LORES_KEY;
- if( s = FindToolType( tarray, "FONTNAME" )){
- if(strlen(s)>30)
- strncpy( FONTNAME, s, 30 );
- else
- strcpy( FONTNAME, s);
- }
- else
- strcpy( FONTNAME, "topaz.font");
- if( s = FindToolType( tarray, "FONTSIZE" ))
- FONTSIZE = (UWORD) atol( s );
- else
- FONTSIZE = 8;
- for(i=0;i<=11;i++) // The Dri Pen definitions
- if( s = FindToolType( tarray, TTARRAY[i] ))
- DriPens[i] = atol( s );
-
- if( s = FindToolType( tarray, "INTERLEAVED" )){
- if(strcmp( s , "YES") ==0)
- INTERLEAVED=TRUE;
- else
- INTERLEAVED=FALSE;
- }
-
- if( s = FindToolType( tarray, "SHANGHAI" )) {
- if(strcmp( s , "YES") ==0)
- _SHANGHAI=TRUE;
- else
- _SHANGHAI=FALSE;
- }
-
- if( s = FindToolType( tarray, "SHOWNAME" )) {
- if(strcmp( s , "YES") ==0)
- SHOWNAME=TRUE;
- else
- SHOWNAME=FALSE;
- }
-
- if( s = FindToolType( tarray, "POPSTART" )) {
- if(strcmp(s,"YES")==0){
- if(scrreq = (struct rtScreenModeRequester *) // on default pub screen (wb)
- rtAllocRequestA( RT_SCREENMODEREQ, NULL ) ) {
- if(rtScreenModeRequest( scrreq, "Select a mode...",RTSC_Flags,
- SCREQF_DEPTHGAD|SCREQF_SIZEGADS|SCREQF_GUIMODES,TAG_END)){
-
- // screenmode selected, copy parameters...
- ID = scrreq->DisplayID;
- Width = scrreq->DisplayWidth;
- Height = scrreq->DisplayHeight;
- Depth = scrreq->DisplayDepth;
-
- } // if rtScreenRequest()
- rtFreeRequest(scrreq); // free allocated memory
- } // no mem
- else
- rtEZRequest("PubIt-Error:\nNo memory for requester!","OK!",0l,0l);
- } // if POPSTART == YES
- } // if POPSTART is found as tt
-
- FreeDiskObject( dobj );
-
- // read palette
-
- if(strlen(AppName)<=0){
- if( fptr = Open("ENVARC:PubIt.palette",MODE_OLDFILE) ){
- for(i=0;i<768;i++)
- Read(fptr, (UBYTE *)&mycolors[i], sizeof (UBYTE) );
- Close(fptr);
- }
- // else, no default palette saved !
- }
- else{
- sprintf(palname,"%s.pal",AppName);
- if( fptr = Open(palname,MODE_OLDFILE ) ){
- for(i=0;i<768;i++)
- Read(fptr, (UBYTE *)&mycolors[i], sizeof (UBYTE) );
- Close(fptr);
- }
- }
- return((WORD)1);
- }
- else{
- rtEZRequest("PubIt-Error:\nCan't read Icon-Tooltypes!","Shit!",0l,0l); // no screen open, yet
- return((WORD)0);
- }
- }
- ///
-
- /// ReplaceTool( )
- static BOOL ReplaceTool(UBYTE **ttarr, UBYTE *ts, UBYTE *rps)
- {
- WORD a = 0;
-
- while (ttarr[a])
- {
- if (strnicmp(ttarr[a], ts, strlen(ts)) == 0)
- {
- ttarr[a] = rps;
- return FALSE;
- }
- a++;
- }
- return TRUE;
- }
- ///
-
- /// SaveCurrSettings( )
- // writes actual settings into tooltypes...
- // supported tooltypes, see above
-
- WORD SaveCurrSettings( struct WBStartup * wbs )
- {
- struct DiskObject *dobj;
- static UBYTE buffer[23][512];
- UBYTE **oldtooltypes, **tarray;
- register int i = 0;
-
- BPTR fptr = NULL; // dos stuff
- UBYTE palname[250]; // app-specific palette
-
- if(!wbs)
- return((WORD)0);
-
- if(strlen(AppName)<=0){
- i=rtEZRequestTags("No AppName given.\nShall I save palette as default?","Yes|No",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- if(i){
- if(!(fptr=Open("ENVARC:PubIt.palette",MODE_NEWFILE))){
- rtEZRequestTags("PubIt-Error:\nCan't open \"ENVARC:PubIt.palette\"\nfor write access!","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- return((int)0);
- }
- for(i=0;i<768;i++)
- Write(fptr, &mycolors[i], sizeof(UBYTE) );
- Close(fptr);
- fptr=NULL;
- } // if
- }
- else { // palette for that specific application
- sprintf(palname,"%s.pal",AppName);
- if(!(fptr=Open(palname,MODE_NEWFILE))){
- rtEZRequestTags("PubIt-Error:\nCan't write \"%s\"!","Shit!",0l,palname,RT_PubScrName,PubScrName,TAG_END);
- return((int)0);
- }
- for(i=0;i<768;i++)
- Write(fptr, &mycolors[i], sizeof(UBYTE) );
- Close(fptr);
- fptr=NULL;
- }
-
- CurrentDir(wbs->sm_ArgList->wa_Lock);
-
- if( dobj = GetDiskObject( wbs->sm_ArgList->wa_Name ))
- {
- tarray = (char **) dobj->do_ToolTypes;
-
- for(i=0;i<=11;i++)
- {
- sprintf( buffer[i], "%s=%ld", TTARRAY[i], DriPens[i] );
- ReplaceTool( tarray, TTARRAY[i], (UBYTE*)&buffer[i] );
- }
-
- sprintf( buffer[12], "PUBNAME=%s",PubScrName);
- ReplaceTool( tarray, "PUBNAME" , (UBYTE*)&buffer[12] );
- sprintf( buffer[12], "PUBTITLE=%s",PubTitle);
- ReplaceTool( tarray, "PUBNAME" , (UBYTE*)&buffer[22] );
- sprintf( buffer[13], "APPNAME=%s",AppName);
- ReplaceTool( tarray, "APPNAME" , (UBYTE*)&buffer[13] );
- sprintf( buffer[14], "APPPRI=%ld", AppPri);
- ReplaceTool( tarray, "APPPRI" , (UBYTE*)&buffer[14] );
- sprintf( buffer[15], "APPSTACK=%ld", AppStack);
- ReplaceTool( tarray, "APPSTACK" , (UBYTE*)&buffer[15] );
- sprintf( buffer[16], "DEPTH=%ld", Depth);
- ReplaceTool( tarray, "DEPTH" , (UBYTE*)&buffer[16] );
- sprintf( buffer[17], "WIDTH=%ld", Width);
- ReplaceTool( tarray, "WIDTH" , (UBYTE*)&buffer[17] );
- sprintf( buffer[18], "HEIGHT=%ld", Height);
- ReplaceTool( tarray, "HEIGHT" , (UBYTE*)&buffer[18] );
- sprintf( buffer[19], "DISPLAYID=%ld", ID );
- ReplaceTool( tarray, "DISPLAYID" , (UBYTE*)&buffer[19] );
- sprintf( buffer[20], "FONTNAME=%s", FONTNAME );
- ReplaceTool( tarray, "FONTNAME", (UBYTE*)&buffer[20] );
- sprintf( buffer[21], "FONTSIZE=%ld", FONTSIZE );
- ReplaceTool( tarray, "FONTSIZE", (UBYTE *)&buffer[21] );
-
- oldtooltypes = dobj->do_ToolTypes;
- dobj->do_ToolTypes = tarray;
-
- if(!PutDiskObject(wbs->sm_ArgList->wa_Name, dobj)){
- rtEZRequestTags("PubIt-Error:\nCan't write Icon-Tooltypes","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- dobj->do_ToolTypes = oldtooltypes;
- FreeDiskObject( dobj );
- return((WORD)0);
- }
- else
- FreeDiskObject( dobj );
- }
- else{
- rtEZRequestTags("PubIt-Error:\nCan't read Icon-Tooltypes!","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- return((WORD)0);
- }
- return((WORD)1); // ok, successfully written
- }
- ///
-
- /// closeall( )
- void closeall( void )
- {
- // Libs Stuff
- if(IconBase) CloseLibrary(IconBase);
- if(DiskfontBase) CloseLibrary(DiskfontBase);
- if(GadToolsBase) CloseLibrary(GadToolsBase);
- if(GfxBase) CloseLibrary((struct Library *)GfxBase);
- if(IntuitionBase) CloseLibrary(IntuitionBase);
- if(ReqToolsBase) CloseLibrary(ReqToolsBase);
- exit(0);
- }
- ///
-
- /// openall( )
- void openall( void )
- {
- // Libs Stuff
- if(ReqToolsBase = OpenLibrary("reqtools.library", 38))
- if(IntuitionBase = OpenLibrary("intuition.library", 39))
- if(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39))
- if(GadToolsBase = OpenLibrary("gadtools.library", 39))
- if(DiskfontBase = OpenLibrary("diskfont.library", 39))
- if(IconBase = OpenLibrary("icon.library", 39))
- return;
- else
- rtEZRequest("Icon Library V39+ required!","OK!",0l,0l);
- else
- rtEZRequest("Diskfont Library V39+ required!","OK!",0l,0l);
- else
- rtEZRequest("GadTools Library V39+ required!","OK!",0l,0l);
- else
- rtEZRequest("Graphics Library V39+ required!","OK!",0l,0l);
- else
- rtEZRequest("Intuition Library V39+ required!","OK!",0l,0l);
- else
- puts("ReqTools Library V38+ required!\n");
-
- closeall( ); // failed, quit.
- }
- ///
-
- /// updatescreen( )
- int updatescreen( void )
- {
- int success = 0;
-
- ClosePubbyMainWindow( );
- CloseDownScreen( );
-
- success=SetupScreen( );
- if(success!=1){ // FATAL ERROR: can't reopen screen
- rtEZRequest("PubIt-Error:\nUnable to reopen screen in\nspecified mode. PubIt quits!","Shit!",0l,0l);
- closeall( );
- exit(0); // no special messy to dos, does somebody care?
- }
-
- success=OpenPubbyMainWindow( ); // try to reopen window
- if(success!=1){
- rtEZRequestTags("PubIt-Error:\nUnable to reopen window.","Quit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- CloseDownScreen( );
- closeall( );
- exit(0); // no special messy to dos, does somebody care?
- }
- ActivateWindow(PubbyMainWnd);
- return((int)1);
- }
- ///
-
- // SubFunctions --------------------
-
- /// driadjust subs
- int driadjust_paletteClicked( void )
- { /* routine when gadget "_Color" is clicked. */
-
- DriPens[SelectedDriPen] = DriPenAdjustMsg.Code ;
- SetAPen(DriPenAdjustWnd->RPort, (long) DriPens[SelectedDriPen] );
- RectFill(DriPenAdjustWnd->RPort, OffX + ComputeX( 178 )+2 ,OffY + ComputeY( 30 )+1 ,
- OffX + ComputeX( 178 ) + ComputeX( 27 ) -3 ,
- OffY + ComputeY( 30 )+2 + ComputeY( 25 )-4 );
-
- return((int) 0 );
- }
-
- int driadjust_pensClicked( void )
- { /* routine when gadget "_Pens" is clicked. */
-
- SelectedDriPen = (int) DriPenAdjustMsg.Code;
- SetAPen(DriPenAdjustWnd->RPort, (long) DriPens[SelectedDriPen] );
- RectFill(DriPenAdjustWnd->RPort, OffX + ComputeX( 178 )+2 ,OffY + ComputeY( 30 )+1 ,
- OffX + ComputeX( 178 ) + ComputeX( 27 ) -3 ,
- OffY + ComputeY( 30 )+2 + ComputeY( 25 )-4 );
- return((int) 0 );
- }
-
- int driadjust_OKClicked( void )
- { /* routine when gadget "_OK" is clicked. */
- return((int) -1 );
- }
- ///
-
- /// app subs
- int app_pathClicked( void )
- { /* routine when gadget "_Path/File:" is clicked. */
- strcpy(AppName, GetString(ApplicationDataGadgets[GD_app_path]) );
- return((int) 0 );
- }
-
- int Gadget12Clicked( void )
- { /* routine when gadget "_Stack:" is clicked. */
- AppStack = (long) GetNumber( ApplicationDataGadgets[GD_Gadget12] ) ;
- return((int) 0 );
- }
-
- int apppriClicked( void )
- { /* routine when gadget "_Priority:" is clicked. */
- AppPri = (long) GetNumber( ApplicationDataGadgets[GD_apppri] ) ;
- return((int) 0 );
- }
-
- int appokClicked( void )
- { /* routine when gadget "_OK" is clicked. */
- return((int) -1 );
- }
-
- int appgetfileClicked( void )
- { /* routine when gadget "" is clicked. */
-
- UBYTE filename[108];
- UBYTE path[108];
- struct rtFileRequester *freq = NULL;
-
- filename[0] = (UBYTE) 0;
- path[0] = (UBYTE) 0;
-
- if(!( GetCurrentDirName( (STRPTR) path, 108 ) ) )
- strcpy(path, "SYS:");
-
- if(!( freq = (struct rtFileRequester *)rtAllocRequestA( RT_FILEREQ,NULL ) ) ){
- rtEZRequestTags("PubIt-Error:\nNo memory for file requester!","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- return((int) 0);
- }
-
- rtChangeReqAttr( (APTR)freq, RTFI_Dir, path, TAG_END);
-
- if(!( rtFileRequest( freq, filename, "Select Application",
- RTFI_Flags, FREQF_PATGAD, RT_PubScrName,PubScrName,TAG_END ) ) ){
- return( (int) 0 ); // user didn't select s.th.
- }
-
- strcpy(path, freq->Dir);
-
- if(path[strlen(path)-1]!=':' && path[strlen(path)-1]!='/')
- strcat(path,"/");
- strcat(path,filename);
-
- rtFreeRequest(freq);
-
- strcpy(AppName, path);
- GT_SetGadgetAttrs(ApplicationDataGadgets[GD_app_path],ApplicationDataWnd,NULL,GTST_String,AppName,TAG_END);
- return((int) 1 );
- }
- ///
-
- /// main subs
- int PubbyMainsmode( void )
- { /* routine when (sub)item "Screen Mode..." is selected. */
-
- struct rtScreenModeRequester *scrreq = NULL;
- int success = 0;
-
- if(scrreq = (struct rtScreenModeRequester *)
- rtAllocRequestA( RT_SCREENMODEREQ, NULL ) ) {
-
- if(rtScreenModeRequest( scrreq, "Select a mode...",RTSC_Flags,
- SCREQF_DEPTHGAD|SCREQF_SIZEGADS|SCREQF_GUIMODES,RT_PubScrName,PubScrName,TAG_END)){
-
- // screenmode selected, copy parameters...
- ID = scrreq->DisplayID;
- Width = scrreq->DisplayWidth;
- Height = scrreq->DisplayHeight;
- Depth = scrreq->DisplayDepth;
-
- ClosePubbyMainWindow();
- WinPoint:
- if(CloseDownScreen()!=1){
- rtEZRequestTags("Please close all windows,\nthen click \"Retry!\"","Retry!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- goto WinPoint;
- }
-
- success=SetupScreen( );
- if(success!=1){ // FATAL ERROR: can't reopen screen
- rtEZRequest("PubIt-Error:\nUnable to reopen screen in\nspecified mode. PubIt quits!","Shit!",0l,0l);
- rtFreeRequest(scrreq);
- closeall( );
- exit(0); // no special messy to dos, does somebody care?
- }
-
- success=OpenPubbyMainWindow( ); // try to reopen window
- if(success!=1){
- rtEZRequestTags("PubIt-Error:\nUnable to reopen window.","Quit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- CloseDownScreen( );
- rtFreeRequest(scrreq); // free allocated memory
- closeall( );
- exit(0); // no special messy to dos, does somebody care?
- }
- } // if rtScreenRequest()
- rtFreeRequest(scrreq); // free allocated memory
- return((int)1); // succeeded
- } // no mem
- else
- rtEZRequestTags("PubIt-Error:\nNo memory for requester!","OK!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- ActivateWindow(PubbyMainWnd);
- return((int)0);
- }
-
- int PubbyMaincpalette( void )
- { /* routine when (sub)item "Color-Palette..." is selected. */
- rtPaletteRequest( (char*)"Color-Palette", NULL, RT_PubScrName, PubScrName, TAG_END );
- getcolors( );
- return((int) 0 );
- }
-
- int PubbyMainappdata( void )
- {
- if( OpenApplicationDataWindow( ) == 1 )
- while(HandleApplicationDataIDCMP( ) != -1 )
- ;
- CloseApplicationDataWindow( );
- return((int) 0 );
- }
-
- int PubbyMaindripens( void )
- { /* routine when (sub)item "Define DriPens..." is selected. */
-
- if( OpenDriPenAdjustWindow( ) == 1 )
- while(HandleDriPenAdjustIDCMP( ) != -1 )
- ;
- CloseDriPenAdjustWindow( );
- return((int) 0 );
- }
-
- int PubbyMainfont( void )
- { /* routine when (sub)item "Font..." is selected. */
- struct rtFontRequester *fontreq=0L;
-
- if(fontreq=(struct rtFontRequester*)rtAllocRequestA(RT_FONTREQ,NULL)){
- fontreq->Flags=FREQF_SCALE;
- if(rtFontRequest(fontreq,"Select Font...", RT_PubScrName,PubScrName,TAG_END)){
- strcpy(FONTNAME,fontreq->Attr.ta_Name);
- FONTSIZE=fontreq->Attr.ta_YSize;
- }
- else{
- rtFreeRequest(fontreq);
- return((int) 0);
- }
- rtFreeRequest(fontreq);
- fontreq=0L;
- }
-
- // new font selected
-
- ClosePubbyMainWindow( );
- CloseDownScreen( );
-
- ScrAttr.ta_Name = (STRPTR) NULL;
- ScrAttr.ta_YSize = 0;
-
- if(SetupScreen( ) == 1 )
- if(OpenPubbyMainWindow( ) == 1)
- return((int)1);
- else
- rtEZRequestTags("PubIt-Error:\nUnable to reopen Window!","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- else
- rtEZRequest("PubIt-Error:\nUnable to reopen Screen!","Shit!",0l,0l);
-
- if(Scr)
- CloseDownScreen( );
- closeall( );
- exit(0);
- }
-
- int PubbyMainabout( void )
- { /* routine when (sub)item "About" is selected. */
- rtEZRequestTags("PubIt 1.01\nCopyright © 1994 by Chris (Confusio) Rickers\n\nThis is Cardware (if you like it, send me a postcard)","I see!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- return((int) 0 );
- }
-
- int PubbyMainsave( void )
- { /* routine when (sub)item "Save..." is selected. */
- if(!(SaveCurrSettings(IconArgs)==1))
- rtEZRequestTags("PubIt-Error:\nCan't write tooltypes, no data saved.","OK!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- return((int) 0 );
- }
-
- int PubbyMainquit( void )
- { /* routine when (sub)item "Quit." is selected. */
- return((int) -1 );
- }
-
- int PubbyMainCloseWindow( void ) // this won't be called, due to borderless window without close gadget
- { /* routine for "IDCMP_CLOSEWINDOW". */
- return((int) -1 );
- }
- ///
-
- /// gui subs
- int DriPenAdjustCloseWindow( void )
- { /* routine for "IDCMP_CLOSEWINDOW". */
- return((int) -1 );
- }
-
- int ApplicationDataCloseWindow( void )
- { /* routine for "IDCMP_CLOSEWINDOW". */
- return((int) -1 );
- }
- ///
-
- // main program ----------------
-
- void main( int argc, char **argv)
- {
- short success = 0;
-
- openall( );
-
- if(argc==0) // started from wb
- IconArgs = (struct WBStartup *)argv;
- else{
- rtEZRequest("Sorry, PubIt must be started from Workbench!","I'll try",0l,0l);
- exit(0);
- }
-
- if(!(ParseIconArgs(IconArgs)==1))
- rtEZRequest("Using defaults!","OK!",0l,0l);
-
- if(!(SetupScreen( ) == 1 ))
- {
- rtEZRequest("PubIt-Error:\nUnable to open requested Screen!","Shit!",0l,0l);
- goto EndPubby;
- }
- else
- {
- if(!(OpenPubbyMainWindow( ) == 1 )){
- rtEZRequestTags("PubIt-Error:\nUnable to open main backdrop window!","Shit!",0l,0l,RT_PubScrName,PubScrName,TAG_END);
- CloseDownScreen( );
- goto EndPubby;
- }
- else {
-
- // if application is specified, start it...
- ClearMenuStrip(PubbyMainWnd);
- RunApp( );
- SetMenuStrip(PubbyMainWnd, PubbyMainMenus);
- if(FQUIT)
- goto pubbyex;
- if(FWQUIT) {
- // wait until the first custom window is opened on pubby screen
- while(!(Scr->FirstWindow->NextWindow))
- Delay(100L);
-
- // now wait until last non pubby window is closed
-
- // *******************************************************************
- // if s.o likes to, here is room for improvement: *
- // NOTE: this is a busy loop, it's better to use signal ports and *
- // check it this way. *
- // but I have a fast system ... (and no time...!) *
- // *******************************************************************
-
- while(Scr->FirstWindow->NextWindow)
- ;
- goto pubbyex;
- }
- while( ! ( success = (short) HandlePubbyMainIDCMP( ) == -1 ) ) // pubby idcmp parser
- ;
- }
- if(!(SaveCurrSettings(IconArgs)==1))
- rtEZRequestTags("Seems you need to specify the tooltypes next time again, Hö!","Blabla",0l,0l,RT_PubScrName,PubScrName,TAG_END);
-
- pubbyex:
- ClosePubbyMainWindow( );
- CloseDownScreen( );
- }
-
- EndPubby:
- closeall( );
- }
-
-
-